package cluedo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import javax.swing.ImageIcon;


/** Carta personaggio*/
public class Character extends Card {
	

	private static final long serialVersionUID = -8015413166145010527L;
	
	/**
	 * I possibili nomi dei personaggi associati ai path
	 */
	private final static HashMap<String,String> characters = new HashMap<String,String>();
	static {
		characters.put("Rev. Green", "/img/green.jpg");
		characters.put("Colonel Mustard", "/img/mustard.jpg");
		characters.put("Miss Scarlett", "/img/scarlett.jpg");
		characters.put("Professor Plum", "/img/plum.jpg");
		characters.put("Mrs White", "/img/white.jpg");
		characters.put("Mrs Peacock", "/img/peacock.jpg");
    }
	
	/**
	 * Costruttore carta personaggio
	 * @param name il nome del personaggio
	 */
	public Character(String name){
		
		if(characters.containsKey(name)){
			this.name=name;
			setImage();
		}
		else
        	System.err.println("Character: Il nome del personaggio non e' valido");
		
	}		
	
	@Override
	protected void setImage(){
		
		cardImage = new ImageIcon(Character.class.getResource(characters.get(this.name))); 
	}

	/**
	 * Restituisce una lista di tutte le carte personaggio
	 * @return vedi descrizione
	 */
	public static List<Character> allCharacters() {
		
		List<Character> list= new Vector<Character>(characters.size());
		
		for(Map.Entry<String, String> entry : characters.entrySet()){
			list.add(new Character(entry.getKey()));
		}
		
		return list;
	}
}
